<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Expires" CONTENT="-1">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
<link rel="stylesheet" href="{:C('VSHOP_CSS')}person.css"/>
<script src="{:C('VSHOP_JS')}jquery-1.9.1.min.js"></script>
</head>
<body>
<header>
  <div class="head"><a href="#" class="head-return"></a>
    <h2 class="head-title">个人中心</h2>
  </div>
</header>
<div class="person-bg"> <span class="head-pic">
 <if condition="$result['headimgurl'] eq ''">
<img src="{:C('VSHOP_IMG')}img-other/head-pic-120x120.png">
<else/>
<img src="{$result.headimgurl}">
</if>
</span>

<if condition="$result['nickname'] eq '' ">
  <p>{$result['uname']}</p>
  <else/>
     <p>{$result['nickname']}</p>
  </if>
</div>

<div class="blank10-f5"></div>
<div class="person-items-box">
  <dl>
    <dd><a href="{:U('Order/index')}"><span class="ico-1"></span>
      <p>我的订单</p>
      <em class="more"></em></a></dd>
    
    <dd><a href="{:U('Address/index')}"><span class="ico-5"></span>
      <p>收货地址管理</p>
      <em class="more"></em></a></dd>
    <!-- <dd><a href=""><span class="ico-6"></span>
       <p>设置</p>
      <em class="more"></em></a>
    </dd>  -->
       <dd><span class="ico-3"></span>
      <p class="myqrcode">我的推广二维码</p>
      <em class="more"></em>
      </dd>
      <dd><span class="ico-1"></span>
      <a href="javascript:void(0)" class="myincome" ><p>我的推广收入</p></a>
      <a href="javascript:void(0)" class="myincome"><em class="more"></em></a>
      </dd>
  </dl>
</div>
<img src="http://qr.liantu.com/api.php?text=http://api.szl66.com/vshop.php?uid={$_SESSION['uid']}" id="qrcode" style='display:none;'>
<!-- 分成图表start -->
 <div id="main" style="height:400px;margin-bottom: 20px;display:none" >
   <table id="incomelogs">
      <thead>
      <tr><th>ID</th><th>订单号</th><th>结算时间</th><th>下线</th><th>提成</th> </tr>
      </thead>
      <tbody>
      <tr>
       <td></td> 
       <td></td>
       <td></td>
       <td></td>
       <td></td> 
      </tr>
      </tbody>
      <tfoot> <tr><td colspan="5">
               <button value='' class="nexpage" onclick=getincome(this.value)>下一页</button> 
               <button value="" class="prepage" onclick=getincome(this.value)>上一页</button> 
               <button class="currentpage" >当前页:<i></i>页</button>
               <button class="pagetotal" >总页数:<i></i>页</button> 
      </td></tr></tfoot>
 </table>

 </div>
 <!-- 分成图表end -->
<include file="Public:footer"/>
<script type="text/javascript" src="__PUBLIC__/common/js/layer/layer.js"></script>
<script type="text/javascript">
  $('.myqrcode').on('click',function(){
    layer.open({
    type: 1,
    title: false,
      area: ['300px', '325px'],
    closeBtn: 1,
    skin: 'layui-layer-nobg', //没有背景色
    content: $('#qrcode')
});
  })
  $('.myincome').on('click',function(){
      getincome();
      layer.open({
      type: 1,
      title: '结算记录',
      skin: 'layui-layer-rim', //加上边框
      area: ['90%', '80%'], //宽高
      content: $('#main')
  });
  })
  
</script>
<script type="text/javascript">
  
  function getincome(e){
    //如果表单显示，直接隐藏，不发送ajax
    //var temp=$('#main').css('display');
   // if(temp=='block') {$('#main').css('display','none'); return false;}
    var $page=(e<=1)?1:e;
    $.ajax({
      method:'POST',
      url:"{:U('User/getIncome')}",
      data:{'page':$page},
      dataType:'JSON',
      success:function(message)
      {
          
          if(message.status)
          {
              var items=message.logs;
              var $page=message.pagearr;
              //替换元素
              var $tbody=$('<tbody></tbody>');
              var $string='';
              $(items).each(function(key,item){
                $string+='<tr><td>'+item.id+'</td>';
                $string+="<td>"+item.order_sn+"</td>";
                $string+="<td>"+item.addtime+"</td>";
                $string+="<td>"+item.nickname+"</td>";
                $string+="<td>"+item.money+"</td>";
              })////遍历数据end
              $tbody.append($string);
              $($tbody).replaceAll("#incomelogs  tbody");
               //替换分页
               $(".pagetotal i").html($page.pagetotal);
               $(".currentpage i").html($page.page);
               $('.prepage').attr('value',$page.prevpage);
               $('.nexpage').attr('value',$page.nextpage);
              // $('.laspage').attr('value',$page.pagetotal);    
              $('#main').show();
              return false;
          }else{
             $('#incomelogs tbody tr').html(message.msg);
             return false;
          }
         
      }
    })
  }
</script>
</body>
</html>
